<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%--项目绝对路径--%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<%

    String url = "jdbc:mysql://localhost:3306/carxianyu";
    String user = "root";
    String pwd = "root";
    Integer userid = Integer.valueOf(session.getAttribute("id").toString());


    String sql = "select * from liuyan where userid="+userid;

    //jdbc 连接数据库
    Class.forName("com.mysql.jdbc.Driver");//加载驱动
    Connection conn = DriverManager.getConnection("jdbc:mysql://43.142.239.28:13307/carxianyu?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC","root","root");
    PreparedStatement a = conn.prepareStatement(sql);
    ResultSet rs = a.executeQuery();
    System.out.println("执行了sql =====》"+sql);


%>






<head>
    <title>评论信息列表页面</title>
    <!-- 引入css样式和js文件-->
    <meta charset="UTF-8">
    <base href="${ctx}/"/>
    <link rel="stylesheet" href="${ctx}/static/layui/css/layui.css"/>
    <script type="text/javascript" src="${ctx}/static/layui/layui.js"></script>
</head>
<body>
<!--导航条 start-->
<jsp:include page="/head.jsp"/>

<!--导航条 end-->

<!--轮播图 start-->
<jsp:include page="/banner.jsp"/>
<!--轮播图 end-->
<div class="layui-fluid">


    <table class="layui-table">
        <tbody>
        <tr class="layui-bg-blue">
            <th>留言编号</th>
            <th>留言用户</th>
            <th>评论内容</th>
            <th>评论时间</th>
            <th>操作</th>
        </tr>
        <% while(rs.next()){

            //为列表参数初始化

            Integer id = rs.getInt("id");
            String username = rs.getString("username");
            String createtime = rs.getString("createtime");
            String message = rs.getString("message");
            String deleteUri =  "/view/back/liuyan/doLiuyyanExcute.jsp?state=3&id="+id;

        %>


        <tr>
            <td><%=id%></td>
            <td><%=username%></td>
            <td><%=message%>></td>
            <td><%=createtime%></td>
            <td style="width: 180px;">
                <a href="${ctx}<%=deleteUri%>" class="layui-btn layui-btn-danger layui-btn-sm">删除</a>
            </td>
        </tr>

        <%}%>

        </tbody>
    </table>


</div>
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    //定义layui的变量
    var $;
    var layer;
    var element;
    var form;
    layui.use(['element', 'layer', 'jquery', 'form'], function () {
        element = layui.element;
        layer = layui.layer;
        $ = layui.jquery;
        form = layui.form;
        //绑定详情点击事件
        $(".showDetail").click(function () {
            var path = $(this).attr("path");
            layer.open({
                offset: '100px', //设置弹出窗口的位置 上边距100px
                type: 2,  //弹出类型
                skin: 'layui-layer-molv', //样式类名
                title: '评论信息详情查看',
                anim: 2,    //弹出窗口使用的动画
                area: ['800px', '620px'],  //设置弹出窗口的大小 宽度,高度
                shadeClose: true, //开启遮罩关闭
                content: path  //加载内容路径
            });
        })
    });
</script>

</body>
</html>
